﻿<%@ Application Language="C#" %>
<%@ Import Namespace="PokeIn.Comet" %>
<%@ Import Namespace="System.Net" %>

<script runat="server">
    
    void Application_Start(object sender, EventArgs e) 
    {
        //Faster & Secure Transfers
        CometSettings.Base64EncyrptedTransfers = true;

        //Reduce the load
        CometSettings.ChunkedMode = true;

        //Since we are not going to develop a DesktopClient for this sample better keep it false (Security)
        CometSettings.AcceptDesktopClients = false;

        //Activate WebSocket feature
        CometSettings.SocketPort = 36925;
        CometSettings.SocketServerIP = IPAddress.Parse("127.0.0.1");

        //CometWorker.OnClientConnected += new DefineClassObjects(CometWorker_OnClientConnected);
        CometWorker.OnClientCreated += new ClientCreatedDelegate(CometWorker_OnClientCreated);
        CometWorker.OnClientDisconnected += new ClientDisconnectedDelegate(CometWorker_OnClientDisconnected);
        
        //start notify
        NotifyToClient ntc= new NotifyToClient();
        ntc.Start();
        
        //start check timeout
        CheckTimeOutItemThread cto = new CheckTimeOutItemThread();
        cto.Start();
    }

    void CometWorker_OnClientDisconnected(string clientId)
    {
        //PokeIn already cleans the individual object instances of that client
    }

    void CometWorker_OnClientCreated(string clientId)
    {
        //client is created and ready. You can start sending messages
    }

    //void CometWorker_OnClientConnected(ConnectionDetails details, ref Dictionary<string, object> classList)
    //{
    //    if (Request.IsAuthenticated)
    //    {
    //        classList.Add("MyClients", new MyClients(details.ClientId));
    //    }
    //}
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
       
</script>
